package com.api.shopapi.service.impl;

import com.api.shopapi.entity.GoodsSize;
import com.api.shopapi.mapper.GoodsSizeMapper;
import com.api.shopapi.service.GoodsSizeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("GoodsSizeServiceImplOne")
public class GoodsSizeServiceImpl implements GoodsSizeService {

    @Autowired
    private GoodsSizeMapper GoodsSizeMapper;

    @Override
    public int insert(GoodsSize goodsSize) {
        return GoodsSizeMapper.insert(goodsSize);
    }

    @Override
    public int update(GoodsSize goodsSize) {
        return GoodsSizeMapper.update(goodsSize);
    }

    @Override
    public GoodsSize getByName(String name) {
        return GoodsSizeMapper.getByName(name);
    }

    @Override
    public GoodsSize getByGoodsSizeCode(String goodsSizeCode) {
        return GoodsSizeMapper.getByGoodsSizeCode(goodsSizeCode);
    }

    @Override
    public PageInfo<GoodsSize> getList(int pageIndex, int pageSize, int status, String name) {
        PageHelper.startPage(pageIndex,pageSize);
        List<GoodsSize> goodsSizeList =GoodsSizeMapper.getList(status,name);
        return new PageInfo<>(goodsSizeList);
    }

    @Override
    public List<GoodsSize> getAllList() {
        return GoodsSizeMapper.getAllList();
    }
}
